package com.beiding.businessplatform.data;

import java.util.Set;

//基本变更单元
public class BaseUnit implements CacheUnit<Object> {

    //对应的字段
    private String field;

    //值
    private Object value;

    private Vm vm;

    public BaseUnit(Vm vm, String field) {
        this.vm = vm;
        this.field = field;
    }

    @Override
    public void write(Set<Vm> vmPath) {
        //生成Be对象
        HolderMap map = vm.holderMap();
        map.get(field).set(value);
    }

    @Override
    public Object read() {
        return value;
    }

    public void update(Object value) {
        this.value = value;
        write(null);
    }

    public void setValue(Object value) {
        this.value = value;
    }
}
